package com.recruit.wechat.controller;


import com.recruit.wechat.bean.WechatArea;
import com.recruit.wechat.bean.WechatLabelType;
import com.recruit.wechat.controller.helper.$;
import com.recruit.wechat.controller.model.ApiResultModel;
import com.recruit.wechat.mapper.WechatLabelTypeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import com.recruit.wechat.bean.result.ResultPage;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ResponseBody;

import com.recruit.wechat.bean.WechatLabel;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author LF
 * @since 2020-08-25
 */
@Controller
@RequestMapping("/WeChatUser/wechatLabel")
public class WechatLabelController extends BaseController{
     /** 主页面 */
    @RequestMapping("admin/main.html")
    public String main(){
       return  "wechatLabel/WechatlabelMain";
    }
    /** 添加页面跳转
     * @return 返回页面
     */
    @RequestMapping(value = "admin/addWechatLabelHtml")
    public String addWechatLabelHtml(Model model ){
        return "wechatLabel/WechatlabelAdd";
    }
    /** 编辑页面跳转
     * @param  id  前端传进的参数
     * @return 返回页面
     */
    @RequestMapping(value = "admin/editWechatLabelHtml")
    public String editWechatLabelHtml(Integer id ,Model model ){
           model.addAttribute("wechatLabel",wechatLabelService.selectWechatLabelByIdWechatLabel(id));
             return "wechatLabel/WechatlabelEdit";
    }

    /** 查看页面跳转
     * @param  id  前端传进的参数
     * @return 返回页面
     */
    @RequestMapping(value = "admin/showWechatLabelHtml")
    public String showWechatLabelHtml(Integer id ,Model model ){
           model.addAttribute("wechatLabel",wechatLabelService.selectWechatLabelByIdWechatLabel(id));
             return "wechatLabel/WechatlabelShow";
    }


    /** 分页查询WechatLabel
     * @param page  页码
     * @param limit  查几条
     * @param wechatLabel  前端传进的参数
     * @return 返回统一分页信息
     */
    @RequestMapping(value = "admin/findWechatLabelByPage")
    @ResponseBody
    public ResultPage findWechatLabelByPage(Integer page, Integer limit,WechatLabel wechatLabel){
             return wechatLabelService.findWechatLabelByPage(page,limit,wechatLabel);
    }

    /** 添加WechatLabel
     * @param wechatLabel  前端传进的参数
     * @return 返回统一信息
     */
    @RequestMapping(value = "admin/addWechatLabel")
    @ResponseBody
    public ApiResultModel saveWechatLabel(WechatLabel wechatLabel  ){
             return wechatLabelService.addWechatLabel(wechatLabel);
    }

    /** 下拉选择标签类型
     * @return 返回统一信息
     */
    @RequestMapping(value = "admin/selectWechatLabelType")
    @ResponseBody
    public ApiResultModel selectWechatLabelType(){
        List<WechatLabelType> list = wechatLabelTypeService.list();
        return $.success(200,"ok",list);
    }

    /** 编辑WechatLabel
     * @param wechatLabel  前端传进的参数
     * @return 返回统一信息
     */
    @RequestMapping(value = "admin/editWechatLabel")
    @ResponseBody
    public ApiResultModel editWechatLabel(WechatLabel wechatLabel  ){
             return wechatLabelService.editWechatLabel(wechatLabel);
    }



    /** 删除一条WechatLabel
     * @param id  前端传进的ID
     * @return 返回统一信息
     */
    @RequestMapping(value = "admin/delWechatLabel")
    @ResponseBody
    public ApiResultModel delWechatLabel( Integer id  ){
        return wechatLabelService.delWechatLabel(id);
    }

}
